package com.waitingresult.zuo.sort;

import java.util.Arrays;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-10-24  13:44
 * @Description: 插入排序
 * @Version: 1.0
 */
public class InsertSort {
    public static void main(String[] args) {
//        int[] arr = {70, 2, 12, 4, 463, 678, 8, 9, 33, 6};
//        sort(arr);
        int i = 1, b = 2;
//        i = 2; b = 2;

        i = i ^ b;
        b = i ^ b;
        i = i ^ b;
        System.err.println(i+"   "+b);
    }

    public static void sort(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            int newNumberIndex = i;
            while (newNumberIndex - 1 >= 0 && arr[newNumberIndex - 1] > arr[newNumberIndex]) {
                int num = arr[newNumberIndex];
                arr[newNumberIndex] = arr[i];
                arr[i] = num;
                newNumberIndex--;
            }

        }
        System.err.println(Arrays.toString(arr));
    }
}
